package com.power.sifa.info.model;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import com.power.sifa.info.model.enumeration.Tp_docgroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
*  法律表实体类
*/

@Entity
@ApiModel(value="法律表")
@Data
@Table(name="Law_doc",schema="sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
//@IdClass(Law_doc.Law_docPK.class) 用于复合组件
public class Law_doc extends BaseModel implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "编码")
    private String id;

    @ApiModelProperty(value = "名称")
    private String title;

    @ApiModelProperty(value = "法律性质")
    private Integer type;

    @ApiModelProperty(value = "发布机关id")
    private String pubunitid;

    @ApiModelProperty(value = "发布机关名称")
    private String pubunitname;

    @ApiModelProperty(value = "发布日期")
    @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
    private Date pubdate;

    @ApiModelProperty(value = "施行日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date execdate;

    @ApiModelProperty(value = "有效性")
    private Integer status;

    @ApiModelProperty(value = "失效日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date losedate;

    @ApiModelProperty(value = "收录日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date recorddate;

    @ApiModelProperty(value = "来源途径")
    private Integer source;

    @ApiModelProperty(value = "发布文号")
    private String pubcode;

    @ApiModelProperty(value = "附件id")
    private String fileid;

    @ApiModelProperty(value = "版本号")
    private String versions;

    @ApiModelProperty(value = "法律文书分类码")
    private Integer groups = Tp_docgroup.EDUCATION;



    /**
     *  法律性质文本
     */
    @Transient
    @FieldEnumText(eum="Tp_law", valuefield="type")
    private String type_text;

    /**
     *  有效性文本
     */
    @Transient
    @FieldEnumText(eum="St_law", valuefield="status")
    private String status_text;

    /**
     *  来源途径文本
     */
    @Transient
    @FieldEnumText(eum="Tp_lawsrc", valuefield="source")
    private String source_text;


    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("title", this.getTitle());
        map.put("type_text", this.type_text);
        map.put("type", this.getType());
        map.put("pubunitid", this.getPubunitid());
        map.put("pubunitname", this.getPubunitname());
        map.put("pubdate", this.getPubdate());
        map.put("execdate", this.getExecdate());
        map.put("status_text", this.status_text);
        map.put("status", this.getStatus());
        map.put("losedate", this.getLosedate());
        map.put("recorddate", this.getRecorddate());
        map.put("source_text", this.source_text);
        map.put("source", this.getSource());
        map.put("pubcode", this.getPubcode());
        map.put("fileid", this.getFileid());
        map.put("versions", this.getVersions());
        map.put("groups", this.getGroups());
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Law_docPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String)key;

        //Law_docPK pk = (Law_docPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}